public class Computer {
    public void powerOn(){
        System.out.println("电脑开机");
    }
    public void powerOff(){
        System.out.println("电脑关机");
    }
    public void useDevice(USB usb){      //接收类型为USB类
        usb.openDevice();
        usb.closeDevice();
        if(usb instanceof Mouse){
            Mouse mouse=(Mouse) usb;  //向下转型
            mouse.click();
        }
        if(usb instanceof KeyBoard){
            KeyBoard keyBoard=(KeyBoard) usb;   //向下转型
            keyBoard.input();
        }
    }
}

